package com.itheima.practise;

import java.util.Random;

public class Test004 {
    public static void main(String[] args) {

        int[] arr = new int[7];
        Random r = new Random();
        //使用for循环嵌套,给数组的前6个赋值,并保证数组前六元素是唯一的
        for (int i = 0; i < arr.length-1; i++) {
            arr[i] = r.nextInt(32)+1;
            for (int j = 0; j < i; j++) {
                if (arr[i] == arr[j]){
                    i--;
                }
            }
        }
        arr[6] = r.nextInt(16)+1;
        System.out.println("红球为");
        for (int i = 0; i < arr.length-1; i++) {
            System.out.println(arr[i]);
        }
        System.out.println(arr[6]);
    }
}
